package com.pocket.demo.business.controller;

import cn.hutool.json.JSONObject;
import com.pocket.demo.base.api.R;
import com.pocket.demo.business.service.ConfigurationService;
import com.pocket.demo.core.i18n.MessageSourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Tag(name = "系统模块", description = "系统信息管理相关接口")
@Validated
@RestController
@RequestMapping("configuration")
public class ConfigurationController {

    @Resource
    private MessageSourceService messageSourceService;
    @Resource
    private ConfigurationService configurationService;

    @Operation(summary = "设置log-level", description = "设置log-level【demo-logback-4】")
    @PutMapping("log-level")
    public R logLevel(@RequestBody JSONObject levelConfig){
        configurationService.updateLogLevel(levelConfig);
        return messageSourceService.getOkResult();
    }
}
